﻿using System;
using System.Collections.Generic;
using System.Text;
using CoreWf;
using CoreWf.Statements;
using CoreWf.Expressions;

namespace netcoreWF
{
    public class FlightTaskActivity : Activity
    {
        private Variable<bool> isEnterFlightsForeach { get; set; } = new Variable<bool> { Name = "isforeachenter", Default = false };

        public FlightTaskActivity()
        {
            this.Implementation = () =>
            {
                //Variable<string> inputsVar1 = new Variable<string> { Default = inputs };

                FlowStep delay2Step = new FlowStep
                {
                    Action = new Delay
                    {
                        Duration = TimeSpan.FromSeconds(2)
                    },
                    Next = null
                };


                FlowStep assignStep = new FlowStep
                {
                    Action = new Assign
                    {
                        DisplayName = "AssignIsEnterFlightsForeach",
                        To = new OutArgument<bool>(isEnterFlightsForeach),
                        Value = new InArgument<bool>(false)
                    },
                    Next = delay2Step
                };


                FlowStep logStep = new FlowStep
                {
                    Action = new LoggingActivity("log111"),
                    Next = assignStep
                };

                FlowStep loopAllFlightsStep = new FlowStep
                {
                    Action = null,
                    Next = logStep
                };


                FlowStep delay1Step = new FlowStep
                {
                    Action = new Delay
                    {
                        Duration = TimeSpan.FromSeconds(2)
                    },
                    Next = loopAllFlightsStep
                };

                Flowchart flowchart = new Flowchart
                {
                    DisplayName = "flight task flowchart",
                    Variables = { isEnterFlightsForeach },
                    StartNode = delay1Step,
                    Nodes =
                    {
                        delay1Step ,
                        loopAllFlightsStep,
                        logStep,
                        assignStep,
                        //delay2Step
                    }
                };
                return flowchart;
            };
        }
    }
}
